﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Graphing.Model
{
    public class Scale
    {
        #region Constructors

        public Scale()
        {
        }

        public Scale(double minX, double maxX, double minY, double maxY)
        {
            // Determine which of the X values are larger and set the min and max based on the larger Absolute value.
            if (Math.Abs(maxX) > Math.Abs(minX))
            {
                this.maxX = Math.Abs(maxX);
                this.minX = -Math.Abs(maxX);
            }
            else
            {
                this.maxX = Math.Abs(minX);
                this.minX = -Math.Abs(minX);
            }

            // Determine which of the Y values are larger and set the min and max based on the larget Absolute value.
            if (Math.Abs(maxY) > Math.Abs(minY))
            {
                this.maxY = Math.Abs(maxY);
                this.minY = -Math.Abs(maxY);
            }
            else
            {
                this.maxY = Math.Abs(minY);
                this.minY = -Math.Abs(minY);
            }

            // Calculate the Pixel Multiplier (conversion) (total units / number of pixels in the window).
            converterX = (this.maxX * 2) / 500;
            converterY = (this.maxY * 2) / 500;

            // Calculate the Scale Multiplier (total units / number of 'ticks').
            scaleX = (this.maxX * 2) / 10;
            scaleY = (this.maxY * 2) / 10;
        }
        
        #endregion // Constructors.

        #region Properties

        public double scaleX { get; set; }
        public double scaleY { get; set; }

        public double minX { get; set; }
        public double maxX { get; set; }

        public double minY { get; set; }
        public double maxY { get; set; }

        public double converterX { get; set; }
        public double converterY { get; set; }

        #endregion // Properties.
    }
}
